package com.qiaofang.entity.enums;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

public enum V10ApiResponseCodeEnum implements Serializable {
    SUCCESS("1","无",null),
    FAIL("2","本人",null),
    ;

    private final String no;
    private final String des;
    private final Enum parent;

    /**
     * 私有构造函数
     * @param no
     * @param des
     */
    V10ApiResponseCodeEnum(String no, String des, Enum parent) {
        this.no = no;
        this.des = des;
        this.parent = parent;
    }

    /**
     * @return Returns the no.
     */
    public String getNo() {
        return no;
    }

    /**
     * @return Returns the des.
     */
    public String getDes() {
        return des;
    }

    /**
     * @return Returns the parent.
     */
    public Enum getParent() {
        return parent;
    }

    /**
     * 通过枚举<code>des</code>获得枚举
     *
     * @param des
     * @return
     */
    public static V10ApiResponseCodeEnum getByDescription(String des) {
        if(StringUtils.isBlank(des)){
            return null;
        }
        for (V10ApiResponseCodeEnum menum : values()) {
            if (menum.getDes().equals(des)) {
                return menum;
            }
        }
        return null;
    }
    public static V10ApiResponseCodeEnum getByNo(String no) {
        if(StringUtils.isBlank(no)){
            return null;
        }
        for (V10ApiResponseCodeEnum menum : values()) {
            if (menum.getNo().equals(no)) {
                return menum;
            }
        }
        return null;
    }
}
